//
//  MyTableViewCell.m
//  TravelEveryDay
//
//  Created by 路洪宇 on 15/10/21.
//  Copyright © 2015年 com.lanou3g. All rights reserved.
//

#import "MyTableViewCell.h"
#import "BaseHeader.h"
@implementation MyTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
        self.contentView.backgroundColor = [UIColor colorWithRed:0.98 green:0.97 blue:0.93 alpha:1];
    }
    return self;
}

- (void)createView
{
    //内容图像
    _title_pageImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 120, 120)];
    _title_pageImageView.layer.cornerRadius = 10;
    _title_pageImageView.layer.masksToBounds = YES;
    [self.contentView addSubview:_title_pageImageView];
    
    //标题
    _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(_title_pageImageView.frame.size.width+20, 20,SCREEN_WIDTH- (_title_pageImageView.frame.size.width+25), 45)];
    _titleLabel.numberOfLines = 0.;
    [_titleLabel setFont:[UIFont systemFontOfSize:17.]];
    [self.contentView addSubview:_titleLabel];
    //时间 //地址 //喜欢数
    
    _addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(_titleLabel.frame.origin.x, _titleLabel.frame.origin.y + _titleLabel.frame.size.height,_titleLabel.frame.size.width, 20)];
    _addressLabel.font = [UIFont systemFontOfSize:14];
    _addressLabel.textColor = [UIColor grayColor];
    _addressLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
    [self.contentView addSubview:_addressLabel];
    
    //价格
    _priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(_titleLabel.frame.origin.x,_title_pageImageView.frame.size.height-20 ,120, 20)];
    [_priceLabel setTextAlignment:NSTextAlignmentLeft];
    _priceLabel.textColor = [UIColor colorWithRed:1 green:0.43 blue:0.01 alpha:1];
    _priceLabel.font = [UIFont boldSystemFontOfSize:22.];
    [self.contentView addSubview:_priceLabel];
    
}

- (void)getInfo:(PlayModel *)model
{
    [self.title_pageImageView sd_setImageWithURL:[NSURL URLWithString:model.title_page]];
    [self.titleLabel setText:model.title];
    
    [self.addressLabel setText:[NSString stringWithFormat:@"出发日期: %@",model.date_str]];
    //self.priceLabel.text = [NSString stringWithFormat:@"%@.0元起", model.price];
    NSMutableAttributedString *mutableString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"￥%@", model.price]];
    [mutableString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:13.0] range:NSMakeRange(0, 1)];
    self.priceLabel.attributedText = mutableString;
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
